home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ML_BME1.ZIP / RIPPLES / RIP_ASM.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-12-21  |  3.6 KB  |  134 lines

  1. ; Ripples generator, by Maple Leaf, Nov 1996
  2. ; "version" 2.0
  3. ; This code is unoptimized. Even so, it is fast enough for my needs. Isn't
  4. ; the assembler wonderful ???
  5. ; a.s.s.e.m.b.l.e.r  r.u.u.u.u.u.l.e.z   !.!.!.!
  6. ;----------------------------------------------------------------------------
  7. ; You may use this piece of code in your productions, as long as you
  8. ; remember to send some greetings to Maple Leaf (Gruian Radu). Don't be
  9. ; a selfish lamer, okay?  Thanx.
  10.  
  11. GapsFilling = 1          ;  0 = the upper and lower "gaps" will be filled
  12.                          ;      with black (background colour)
  13.                          ;  1 = the gaps will be filled with pixels which
  14.                          ;      appear in the opposite part of the screen.
  15.                          ;
  16.                          ;  I don't advise you to put here another value
  17.                          ; different from 0 or 1...
  18.  
  19. .model TPascal
  20. .386
  21.  
  22. .DATA
  23.  
  24.         extrn    Img:DWORD
  25.         extrn    vScr:WORD
  26.         extrn    sqrTab:WORD
  27.         extrn    Wave:WORD
  28.  
  29. .CODE
  30.  
  31.         public   DrawRipples
  32.  
  33. include jumps.inc
  34.  
  35. ;--- psycho !!! -------------------------------------------------------------
  36.  
  37. proc    DrawRipples near
  38.  
  39.         pusha
  40.         push     ds es fs gs bp
  41.         mov      cx,64000 ; the whole virtual screen
  42.  
  43.         mov      di,0   ; offs=0
  44.         mov      bx,0   ; x=0
  45.         mov      dx,0   ; y=0
  46.  
  47.         mov      es,vScr
  48.         push     ds
  49.         pop      fs
  50.         assume   fs:DATA
  51.         mov      gs,fs:sqrTab
  52.         mov      ds,fs:Img[2]
  53.  
  54. @ML:    mov      ax,bx    ; ax=x
  55.         sub      ax,160   ; ax=x-160
  56.         sjge     @ge1
  57.         neg      ax
  58.  
  59. @ge1:   mov      si,dx    ; si=y
  60.         sub      si,100   ; si=y-100
  61.         sjge     @ge2
  62.         neg      si
  63.  
  64. @ge2:   mov      bp,si
  65.         shl      si,7
  66.         add      si,bp
  67.         shl      bp,5
  68.         add      si,bp  ; si = yy*161 = (yy shl 7 + yy shl 5 + yy)
  69.         add      si,ax  ; ... + xx
  70.         add      si,si  ; (...)*2
  71.  
  72.         mov      si,gs:[si]      ; si = sqrTab:[...] = distance to origin
  73.         add      si,si
  74.         mov      si,fs:Wave[si]  ; si = Wave[distance]  = altitude of this point
  75.  
  76.         add      si,dx   ; si = y + Altitude
  77.         sjl      less2   ;
  78. go2:    cmp      si,199  ;  check if range 0-199
  79.         sja      above2  ;
  80. go3:
  81.         mov      bp,si
  82.         shl      si,8
  83.         shl      bp,6
  84.         add      si,bp   ; si = (y+Altitude) * 320
  85.         add      si,bx   ; ... + x
  86.  
  87.         mov      al,[si]     ;
  88. go4:    mov      es:[di],al  ;  copy that motherfucking byte
  89.         inc      di          ;
  90.  
  91.         inc      bx       ; inc(x)
  92.         cmp      bx,319   ; out of range ?
  93.         sja      above    ; next y !
  94.  
  95. @goon:  dec      cx
  96.         jnz      @ML
  97.  
  98.         pop      bp gs fs es ds
  99.         popa
  100.  
  101.         retn
  102.  
  103. above2:
  104.  
  105. IF GapsFilling ne 0
  106.         sub     si,200         ;
  107.         jmp     short go3      ; these two will use the opposite extremes to fill the gaps
  108. ENDIF
  109.  
  110. IF GapsFilling ne 1
  111.         mov     al,0            ;
  112.         jmp     short go4       ; these two will fill with black the extreme portions
  113. ENDIF
  114.  
  115. less2:
  116.  
  117. IF GapsFilling ne 0
  118.         add     si,200         ;
  119.         jmp     short go2      ; these two will use the opposite extremes to fill the gaps
  120. ENDIF
  121.  
  122. IF GapsFilling ne 1
  123.         mov     al,0            ;
  124.         jmp     short go4       ; these two will fill with black the extreme portions
  125. ENDIF
  126.  
  127. above:  mov     bx,0  ; mov x,0
  128.         inc     dx    ; inc y
  129.         jmp     short @goon
  130.  
  131. endp    DrawRipples
  132.  
  133.  
  134.         END